'use strict';
// Copyright 2016 4 28 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview
 * @author 454522799@qq.com (vincentxiaoxu debing)
 */

var dataApi = require('../libs/dataApi');
var _ = require('lodash');

/**
 * 联盟商城
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.getConf = function (union_lv) {
    var list = [];
    var conf = dataApi.union_shop.all();
    if (!conf) {
        console.error('union shop not conf');
        return;
    }
    _.each(conf, function (item) {
        var clone_item = _.clone(item, true);
        clone_item.state = 0;
        if (union_lv >= clone_item.lvl) {
            clone_item.state = 1;
        }
        list.push(clone_item);
    });
    return list;
};

/**
 * 联盟商城
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.getConfById = function (shop_id) {
    var conf = dataApi.union_shop.findById(shop_id);
    if (!conf) {
        console.error('union shop not conf');
        return;
    }
    return conf;
};
